Skip to content

[okyungjin] WEEK 02 solutions#2683

Merged
okyungjin merged 6 commits into
DaleStudy:mainfrom
okyungjin:main
Jul 4, 2026
Merged

[okyungjin] WEEK 02 solutions#2683
okyungjin merged 6 commits into
DaleStudy:mainfrom
okyungjin:main

Conversation

@okyungjin

@okyungjin okyungjin commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@dalestudy

dalestudy Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

📊 okyungjin 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
3sum Medium ✅ 의도한 유형
climbing-stairs Easy ✅ 의도한 유형
product-of-array-except-self Medium ✅ 의도한 유형
valid-anagram Easy ✅ 의도한 유형

누적 학습 요약

  • 풀이한 문제: 5 / 75개
  • 이번 주 유형 일치율: 100% (4문제 중 4문제 일치)

문제 풀이 현황

카테고리 진행도 완료
Heap ■■□□□□□ 1 / 3 (Medium 1)
Array ■□□□□□□ 2 / 10 (Easy 2)
Graph ■□□□□□□ 1 / 8 (Medium 1)
Dynamic Programming ■□□□□□□ 1 / 11 (Medium 1)
Binary □□□□□□□ 0 / 5 ← 아직 시작 안 함
Interval □□□□□□□ 0 / 5 ← 아직 시작 안 함
Linked List □□□□□□□ 0 / 6 ← 아직 시작 안 함
Matrix □□□□□□□ 0 / 4 ← 아직 시작 안 함
String □□□□□□□ 0 / 10 ← 아직 시작 안 함
Tree □□□□□□□ 0 / 14 ← 아직 시작 안 함

🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다.

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 483 37 520 $0.000039
2 934 102 1,036 $0.000088
3 1,500 111 1,611 $0.000119
4 1,604 129 1,733 $0.000132
5 2,367 166 2,533 $0.000185
합계 6,888 545 7,433 $0.000562

@github-actions github-actions Bot added the py label Jun 29, 2026
@okyungjin okyungjin changed the title 242. Valid Anagram [okyungjin] WEEK 02 solutions Jun 29, 2026
@dahyeong-yun dahyeong-yun self-requested a review June 29, 2026 13:23
Comment on lines +20 to +22
curr = prev2 + prev1 # 현재 계단
prev2 = prev1
prev1 = curr

@dahyeong-yun dahyeong-yun Jul 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
curr = prev2 + prev1 # 현재 계단
prev2 = prev1
prev1 = curr
prev2, prev1 = prev1, prev2 + prev1

파이썬이니까 동시 할당을 활용하는 방법도 있을 것 같아요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다! 개인적으로 curr로 작성해주는게 가독성이 더 좋다고 생각해서 풀어서 작성했습니다.

prev2 = 1 # 전전칸 까지의 경우의 수
prev1 = 2 # 전칸 까지의 경우의 수

for _ in range(2, n):

@dahyeong-yun dahyeong-yun Jul 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개인적으로는 3번째 계단에서 시작하는 거면, 3이라고 명시하는 걸 더 선호해서요. 이렇게도 쓸 수 있을 것 같아요.

Suggested change
for _ in range(2, n):
for _ in range(3, n+1):

Comment on lines +21 to +32
if len(s) != len(t):
return False

counter = Counter(s)

for char in t:
if counter[char] >= 1:
counter[char] -= 1
else:
return False

return True

@dahyeong-yun dahyeong-yun Jul 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Counter 라는 것은 처음 보는데 아주 편리하게 쓸 수 있네요. 어차피 Counter 객체를 쓴다면 비교 연산으로 더 간단히 표현이 가능한 것 같아요. 찾아보니 Counter가 내부적으로 각 문자의 등장 횟 수를 dict 타입으로 반환하고, dict 타입은 == 연산자로 동일 비교가 가능하네요.

Suggested change
if len(s) != len(t):
return False
counter = Counter(s)
for char in t:
if counter[char] >= 1:
counter[char] -= 1
else:
return False
return True
# s가 "apple" 일 때, Counter({'p': 2, 'a': 1, 'l': 1, 'e': 1})
return Counter(s) == Counter(t)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dahyeong-yun 오오 이런 방법도 있네요. 파이썬은 == 으로 비교하면 참조가 아니라 값으로 비교하는 특성이 있군요. 감사합니다 ㅎㅎ!!

@okyungjin

Copy link
Copy Markdown
Contributor Author

238. Product of Array Except Self

AI의 도움을 받아 prefix, suffix 이해를 돕는 그림을 그렸습니다.

image

answer[j] *= suffix
suffix *= nums[j]

return answer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔한 풀이네요 👍🏼

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시간이 얼마 안 남아서 남은 것들 후딱 풀겠습니다. 늦은 시간인데도 확인해주셔서 감사해요ㅠㅠ!

@dahyeong-yun dahyeong-yun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한번에 올리려고 했는데, comment를 올리면 바로 올라가 버리는군요 ^^; 코드 살펴보면서 파이썬이나 간결함에 대해 배울 수 있어서 좋았습니다. 늦은 시간 까지 고생 많으세요! 오늘 더 확인은 어려울 것 같아 미리 승인 드립니다. 남은 문제도 화이팅이에요!

@okyungjin

Copy link
Copy Markdown
Contributor Author

한번에 올리려고 했는데, comment를 올리면 바로 올라가 버리는군요 ^^; 코드 살펴보면서 파이썬이나 간결함에 대해 배울 수 있어서 좋았습니다. 늦은 시간 까지 고생 많으세요! 오늘 더 확인은 어려울 것 같아 미리 승인 드립니다. 남은 문제도 화이팅이에요!

@dahyeong-yun 파이썬 재치있는 언어 같아요. 다 풀고 자바 코드도 구경하러 가겠습니다! 늦은 시간인데도 검토해주셔서 감사합니다. 다음주도 파이팅하세요!!

Comment thread 3sum/okyungjin.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Binary Search, Hash Map / Hash Set
  • 설명: 정렬된 배열에서 하나의 포인터를 고정하고 나머지 두 포인터를 양 끝에서 좁혀가며 합이 목표값(0)이 되도록 탐색하는 패턴이다. 중복 제거를 위해 포인터를 움직이며 검사한다. 추가로 간접적으로 정렬과 조건 비교를 이용하는 두 포인터의 결합 방식이다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n^2)
Space O(1)

피드백: 정렬로 정렬된 배열에서 두 포인터를 움직이며 모든 해를 탐색한다. 중복 제거 로직이 포함되어 있다.

개선 제안: 현재 구현이 충분히 효율적이며, 필요 시 초기 i 반복에서 nums[i]가 양수인 경우의 조기에 종료하는 등의 미세 최적화를 고려할 수 있다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

결과는 공간 복잡도에 포함시키지 않나보네요

Comment thread climbing-stairs/okyungjin.py
Comment thread product-of-array-except-self/okyungjin.py
Comment thread valid-anagram/okyungjin.py
@okyungjin okyungjin moved this from Solving to In Review in 리트코드 스터디 8기 Jul 4, 2026
@okyungjin okyungjin merged commit ee9ffda into DaleStudy:main Jul 4, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Review to Completed in 리트코드 스터디 8기 Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants